package com.winsdom.entity.customer;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;

/**
 * 个体户客户信息更新请求
 * 用于接收更新个体户客户信息的请求参数
 */
@Data
@Schema(name = "CustomerIndividualUpdateRequest", description = "个体户客户信息更新请求")
public class CustomerIndividualUpdateRequest {

    @Schema(description = "客户ID", example = "18", required = true)
    @NotNull(message = "客户ID不可为空")
    private Long customerId;

    @Schema(description = "客户类型", example = "2", required = true)
    @NotNull(message = "客户类型不可为空")
    @Min(value = 2, message = "客户类型无效")
    @Max(value = 2, message = "客户类型无效")
    private Integer customerType;

    @Schema(description = "客户名称", example = "个体户名称")
    @Size(min = 2, max = 50, message = "客户名称长度为2至50个字符")
    @Pattern(regexp = "^[\\s\\S]{4,50}$", message = "客户名称长度为4至50个字符")
    private String customerName;

    @Schema(description = "客户手机号", example = "19942222222")
    @Pattern(regexp = "^1\\d{10}$", message = "手机号格式不正确，应为11位数字且以1开头")
    private String mobilePhone;

    @Schema(description = "注册号", example = "22222")
    @Pattern(regexp = "^[A-Za-z0-9]{10,25}$", message = "注册号支持数字或英文10-25位字符")
    private String registrationNumber;

    @Schema(description = "开户行", example = "工商银行")
    @Size(min = 4, max = 30, message = "开户银行长度为4至30个字符")
    private String bankName;

    @Schema(description = "开户行账号", example = "31415926535859793223")
    @Pattern(regexp = "^\\d{12,25}$", message = "银行账号为12至25位数字")
    private String bankAccount;

    @Schema(description = "电子邮箱", example = "gth@example.com")
    @Email(message = "邮箱格式不正确")
    @Size(max = 100, message = "邮箱长度不能超过100个字符")
    private String email;

    @Schema(description = "营业执照图片地址", example = "/images/gth1.jpg")
    @Size(max = 255, message = "图片地址长度不能超过255个字符")
    private String businessLicenseImage;

    @Schema(description = "经营地址区域", example = "[\"浙江省\", \"杭州市\", \"西湖区\"]")
    @Size(max = 100, message = "经营地址区域长度不能超过100个字符")
    private String businessAddressArea;

    @Schema(description = "经营地址区域码", example = "[\"11\", \"1101\", \"110105\"]")
    @Size(max = 50, message = "经营地址区域码长度不能超过50个字符")
    private String businessAddressAreaCode;

    @Schema(description = "经营详情地址", example = "详情地址")
    @Size(max = 200, message = "经营详情地址长度不能超过200个字符")
    private String businessDetailedAddress;

    @Schema(description = "联系人信息列表", example = "[{\"contactName\":\"刘东\",\"contactMobile\":\"13567645888\",\"contactEmail\":\"liudong1@example.com\",\"receiveProperties\":[\"XX花园\",\"海王星大厦\"]}]")
    @Valid
    @Size(max = 5, message = "联系人最多5个")
    private List<ContactInfo> contactInfos;

    @Data
    @Schema(name = "CustomerIndividualUpdateRequest.ContactInfo", description = "个体户联系人信息（更新用）")
    public static class ContactInfo {

        @Schema(description = "客户ID", hidden = true)
        private Long customerId;

        @Schema(description = "联系人ID", example = "1", required = true)
        private Long contactId;

        @Schema(description = "联系人姓名", example = "刘东")
        @Size(min = 2, max = 50, message = "联系人姓名长度为2至50个字符")
        private String contactName;

        @Schema(description = "联系人手机", example = "13567645888")
        @Pattern(regexp = "^\\d{4,11}$", message = "联系人电话为4至11位数字")
        private String contactMobile;

        @Schema(description = "联系人邮箱", example = "liudong1@example.com")
        @Email(message = "联系人邮箱格式不正确")
        @Size(max = 100, message = "联系人邮箱长度不能超过100个字符")
        private String contactEmail;

        @Schema(description = "接收楼盘列表", example = "[\"XX花园\",\"海王星大厦\"]")
        private List<String> receiveProperties;
    }
}